<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Save extends Controller
{
	function setVars()
	{
        define('URI', $this->uri->segment(1).'/'.$this->uri->segment(2));
        define('URL', site_url(URI).'/');
//        define('GETURL',site_url(URI).'/');

		$this->tpl['tpljs'][]  = 'jquery';
		$this->tpl['head'] = '';
		$this->tpl['title'] = 'Save && Message test';
	    $this->tpl['body'] = '';
        
        $this->tpl['link'] = anchor(URI.'/form', 'Form').' | ';
        $this->tpl['link'] .= anchor(URI.'/save', 'Save');


	}
	
	function __construct()
	{
        parent::Controller();
        $this->auth->CheckTaMeR(101);
        $this->load->library('pquery');
        $this->setVars();
	}
    
    
    /**
     * @note	index
     * @info	redirect
     * @author	Dennis T. Kaplan
     * @access	public
     * @param	 
     * @return	
     */	
	function index()
	{
        $this->tpl['body'] .= '<img src="/img/truckbunner.gif"/>';
		$this->load->view('blank', $this->tpl);
	}

    /**
     * @note	Ajax
     * @info	
     * @author	Dennis T. Kaplan
     * @access	public
     * @param	 
     * @return	ajax code
     */	
    public function ajax()
    {
    	$this->tpl['body'] .= $this->pquery->form_remote_tag(array('url'=>URL.'/saveit/','update'=>'#idtoupdate','type'=>'POST'));
        $this->tpl['body'] .= '<p>'.$this->pquery->link_to_remote("Ajax Link",array('url'=>URL.'/ajaxlink/','update'=>'#idtoupdate'));
        $this->form();
    }

    
    /**
     * @note	save
     * @info	
     * @author	Dennis T. Kaplan
     * @access	public
     * @param	 
     * @return	html
     */	
    public function form()
    {
        
        
        $this->tpl['body'] .= 'Field : <input type="text" name="field" value="Whats Up"/><br />';
        $this->tpl['body'] .= '<input type="submit" />';
        $this->tpl['body'] .= '</form><br />';

        $this->tpl['body'] .= '<p><div id="idtoupdate">Update ME(Ajax Link)</div></p>';
        $this->load->view('blank', $this->tpl);
    }

	function ajaxlink()
	{
		echo 'Ajax link Clicked';
	}

    
    /**
     * @note	save
     * @info	
     * @author	Dennis T. Kaplan
     * @access	public
     * @param	 
     * @return	
     */	
    public function saveit()
    {
        echo '<h4>Ajax Form Submitted value: '.$_POST['field'].'</h4>';
    }
}
?>
